package devmanuals.com; import java.util.Deque; import java.util.ArrayDeque; public class DequeContains { public static void main(String args[]) { Deque dqa = new ArrayDeque(); dqa.add("15"); dqa.add("16"); dqa.add("17"); dqa.add("18"); System.out.println("Elements of previous deque are :" + dqa); System.out.println("And the size of deque : " + dqa.size()); System.out .println("Insert a new element '10' at the front of the deque"); // This method will add the element at the front of the deque. dqa.addFirst("14"); System.out.println("Then the new Elements of deque are : " + dqa); System.out .println("Now insert a new element '15' at the end of the deque"); // This method will add the element at the end position of the deque. dqa.addLast("19"); System.out.println("Then the new Elements of deque are : " + dqa); System.out.println("And the size of new deque = " + dqa.size()); // This method will test whether the element '19' is present in deqe or not. boolean bol = dqa.contains("19"); System.out.println("Deque has specified element : " + bol); if (bol == true) System.out .println("Is the specified element present in deque ? : YES"); else System.out .println("Is the specified element present in deque ? : NO"); } }